package com.csi.bumblebee.controller;

import com.csi.bumblebee.domain.dictionary.Industry;
import com.csi.bumblebee.domain.util.MyResult;
import com.csi.bumblebee.domain.util.StateCode;
import com.csi.bumblebee.service.IndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 孙伟俊
 */
@RestController
@RequestMapping("/industry")
public class IndustryController {

    @Autowired
    private IndustryService industryService;

    @GetMapping("/")
    public MyResult<List<Industry>> list(){
        MyResult<List<Industry>> myResult = new MyResult<>();

        List<Industry> industryList = industryService.listFirst();
        if (industryList != null){
            myResult.setData(industryList);
            myResult.setMessage("查询成功");
            myResult.setCode(StateCode.FIND_SUCCESS);
        }else {
            myResult.setCode(StateCode.FIND_FAILURE);
            myResult.setMessage("查询失败");
        }

        return myResult;
    }

}
